package cn.hls.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.hls.dao.ACLDao;
import cn.hls.entity.ACL;
import cn.hls.entity.Module;
import cn.hls.service.ACLService;

@Service("aclService")
public class ACLServiceBean extends BaseServiceBean<ACL> implements ACLService {
	@Resource(name = "aclDaoImpl")
	private ACLDao dao;

	@SuppressWarnings("rawtypes")
	@Override
	public List searchAclRecord(Integer principalType, Long principalId,Long moduleId) throws Exception {
		 return dao.searchAclRecord(principalType, principalId, moduleId);
	}

	@Override
	public void addOrUpdatePermission(Integer principalType,
			Long principalId, Long moduleId, Integer permission,
			boolean yes) throws Exception {
		 dao.addOrUpdatePermission(principalType, principalId, moduleId, permission, yes);

	}

	@Override
	public void addOrUpdateExtPermission(Integer principalType,
			Long principalId, Long moduleId, String ex) throws Exception {
		dao.addOrUpdateExtPermission(principalType, principalId, moduleId, ex);
	}

	@Override
	public void updateEnable(Integer principalType, Long principalId,
			Long moduleId, boolean yes) throws Exception {
		 dao.updateEnable(principalType, principalId, moduleId, yes);

	}

	@Override
	public ACL findACL(Integer principalType, Long principalId,
			Long moduleId) throws Exception {
		return dao.findACL(principalType, principalId, moduleId);
	}

	@Override
	public void addOrUpdateUserEnable(Long userId, Long moudleId,
			Integer yes) throws Exception {
		dao.addOrUpdateUserEnable(userId, moudleId, yes);
	}

	@Override
	public List<Module> searchModules(Long userId) throws Exception {
		return dao.searchModules(userId);
	}

	@Override
	public void delPermission(Integer principalType, Long principalId)
			throws Exception {
		 dao.delPermission(principalType, principalId);
	}

	@Override
	public void delPermission(Integer principalType, Long principalId,
			Long moduleId) throws Exception {
		dao.delPermission(principalType, principalId, moduleId);
	}

	@Override
	public boolean isAclExists(Long moduleId) throws Exception {
		return dao.isAclExists(moduleId);
	}

	@Override
	public boolean hasPermissionByResourceCode(Long userId,
			String moduleCode, int permissionExt) throws Exception {
		return dao.hasPermissionByResourceCode(userId, moduleCode, permissionExt);
	}

	@Override
	public boolean hasPermissionByResourceCode(Long userId,
			String moduleCode, int permissionExt, boolean sys) throws Exception {
		return dao.hasPermissionByResourceCode(userId, moduleCode, permissionExt, sys);
	}

	@SuppressWarnings("rawtypes")
	@Override
	public List findByCode(String code) throws Exception {
		return dao.findByCode(code);
	}

	@Override
	public void deleteAclByModule(Long moduleId) throws Exception {
		dao.deleteAclByModule(moduleId);
	}

}
